package com.cashmama.market.api.domain.handler.order;

import com.cashmama.market.api.infras.enums.PackageNameEnum;
import com.cashmama.market.api.domain.vo.order.RepaymentRecordVO;
import com.google.common.collect.Maps;
import com.qianli.cashmama.product.facade.result.ProductCategory;
import com.qianli.cashmama.trade.client.vo.TradeVO;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @program: market-api
 * @description
 * @author: frank
 * @create: 2020-07-09 16:03
 **/
@Component
public class OrdersHandler {

    public static Map<String, BaseHandler> orderHandlerMap = Maps.newHashMap();

    public List<RepaymentRecordVO> getOderList(List<TradeVO> tradeList, Integer type, String packageName){
        return orderHandlerMap.get(PackageNameEnum.getLowercaseAppName(packageName)).getOderList(tradeList, type);
    }

    /**
     * 根据包名获取产品类目
     * @param packageName
     * @return
     */
    public String getCategoryCode(String packageName){
        return orderHandlerMap.get(PackageNameEnum.getLowercaseAppName(packageName)).getCategoryCode();
    }

    public List<ProductCategory> getProductCategoryList(String packageName, String appCode){
        return orderHandlerMap.get(PackageNameEnum.getLowercaseAppName(packageName)).getProductCategoryList(appCode);
    }



}
